package com.cayden.components.dubbo;

import com.cayden.config.boot.component.ComponentInitializer;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * @author cayden
 * @date 2021-10-27 11:14
 */
public class DubboComponentInitializer implements ComponentInitializer {

    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {
        System.setProperty("dubbo.application.logger", "slf4j");
        Boolean dubboEnable = true;
        if (!applicationContext.getEnvironment().getProperty("cayden.dubbo.enable", Boolean.class, Boolean.TRUE)) {
            dubboEnable = false;
        }
        if (!applicationContext.getEnvironment().getProperty("cayden.dubbo.provider.enable", Boolean.class, Boolean.TRUE)) {
            dubboEnable = false;
        }
        System.setProperty("dubbo.provider.enable", dubboEnable.toString());
    }
}
